/***
 *    This program is free software; you can redistribute it and/or modify
 *    it under the terms of the GNU General Public License as published by
 *    the Free Software Foundation; either version 2 of the License, or
 *    (at your option) any later version.
 *
 *    This program is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU General Public License for more details.
 *
 *    You should have received a copy of the GNU General Public License
 *    along with this program; if not, write to the Free Software
 *    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *    
 *    Linking this library statically or dynamically with other modules 
 *    is making a combined work based on this library. Thus, the terms and
 *    conditions of the GNU General Public License cover the whole
 *    combination.
 *    
 *    As a special exception, the copyright holders of this library give 
 *    you permission to link this library with independent modules to 
 *    produce an executable, regardless of the license terms of these 
 *    independent modules, and to copy and distribute the resulting 
 *    executable under terms of your choice, provided that you also meet, 
 *    for each linked independent module, the terms and conditions of the 
 *    license of that module.  An independent module is a module which 
 *    is not derived from or based on this library.  If you modify this 
 *    library, you may extend this exception to your version of the 
 *    library, but you are not obligated to do so.  If you do not wish 
 *    to do so, delete this exception statement from your version.
 *
 *    Project: www.simpledbm.org
 *    Author : Dibyendu Majumdar
 *    Email  : d dot majumdar at gmail dot com ignore
 */
/*
 * Created on: Nov 14, 2005
 * Author: Dibyendu Majumdar
 */
package org.simpledbm.typesystem.api;

import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.Date;

import org.simpledbm.common.api.registry.Storable;
import org.simpledbm.common.util.Dumpable;

/**
 * A DataValue is a data item with a type, and suitable for use in a
 * multi-column row. The set of values that a DataValue can hold is called its
 * value domain. The value domain is logically bounded by "negative infinity"
 * and "positive infinity", such that:
 * <p>
 * 
 * <pre>
 * null &lt; negative_infinity &lt; value &lt; positive_infinity
 * </pre>
 * 
 * @author Dibyendu Majumdar
 */
public interface DataValue extends Storable, Comparable<DataValue>, Dumpable {

    /**
     * Returns an integer representation of the data value.
     * 
     * @throws UnsupportedOperationException.
     */
    int getInt();

    /**
     * Converts the supplied integer value to a suitable value for the data
     * value
     * 
     * @throws UnsupportedOperationException.
     */
    void setInt(Integer integer);

    /**
     * Returns a string representation of the data value.
     */
    String getString();

    /**
     * Converts the supplied string value to a suitable value for the data value
     */
    void setString(String string);

    /**
     * Sets the value of the field to the date.
     * 
     * @throws UnsupportedOperationException.
     */
    void setDate(Date date);

    /**
     * Gets the current value as a date.
     * 
     * @throws UnsupportedOperationException.
     */
    Date getDate();

    /**
     * Converts the supplied long value to the data value
     * 
     * @throws UnsupportedOperationException.
     */
    void setLong(long l);

    /**
     * Returns the data value as a long
     * 
     * @throws UnsupportedOperationException.
     */
    long getLong();

    /**
     * Converts the supplied BigInteger to the data value
     * 
     * @throws UnsupportedOperationException.
     */
    void setBigInteger(BigInteger i);

    /**
     * Returns the data value as a long
     * 
     * @throws UnsupportedOperationException.
     */
    BigInteger getBigInteger();

    /**
     * Converts the supplied BigDecimal to the data value
     * 
     * @throws UnsupportedOperationException.
     */
    void setBigDecimal(BigDecimal d);

    /**
     * Returns the Data Value as a BigDecimal
     * 
     * @throws UnsupportedOperationException.
     */
    BigDecimal getBigDecimal();

    /**
     * Returns the DataValue as a byte array
     */
    byte[] getBytes();

    /**
     * Sets the DataValue to the byte array
     */
    void setBytes(byte[] bytes);

    /**
     * Checks if the data value is NULL, which is a special value indicating
     * that the field's value has not been set.
     */
    boolean isNull();

    /**
     * Sets the field to be NULL.
     */
    void setNull();

    /**
     * Checks if this field is set to the value signifying negative infinity.
     * Negative infinity represents a value that is less than all the valid
     * values in the field's domain.
     */
    boolean isNegativeInfinity();

    /**
     * Sets this field to the value of negative infinity.
     */
    void setNegativeInfinity();

    /**
     * Checks if this field is set to the value signifying positive infinity.
     * Positive infinity represents a value that is greater than all the valid
     * values in the field's domain.
     */
    boolean isPositiveInfinity();

    /**
     * Sets this field to the value of positive infinity.
     */
    void setPositiveInfinity();

    /**
     * Checks if this field is set to a value in the field's domain.
     */
    boolean isValue();

    /**
     * Returns the TypeDescriptor for the field
     */
    TypeDescriptor getType();

    /**
     * Creates and returns a copy of this field.
     */
    DataValue cloneMe();
}
